```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring核心技术解析 - IOC与AOP</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .highlight {
            background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,236,179,0.5) 20%, rgba(255,236,179,0.5) 80%, rgba(255,255,255,0) 100%);
            padding: 0.2rem 0.5rem;
            border-radius: 4px;
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 3.5rem;
            line-height: 0.65;
            margin: 0.1em 0.2em 0 0;
            color: #667eea;
            font-weight: bold;
        }
        .code-block {
            background-color: #2d3748;
            color: #f7fafc;
            border-radius: 0.5rem;
            overflow-x: auto;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4">Spring核心技术解析</h1>
                    <h2 class="text-2xl md:text-3xl font-semibold mb-6">深入理解IOC与AOP</h2>
                    <p class="text-lg opacity-90 mb-8">掌握Spring框架的两大核心思想，构建高内聚低耦合的企业级应用</p>
                    <div class="flex space-x-4">
                        <a href="#ioc" class="bg-white text-indigo-700 px-6 py-3 rounded-lg font-medium hover:bg-gray-100 transition duration-300">IOC详解</a>
                        <a href="#aop" class="bg-indigo-900 text-white px-6 py-3 rounded-lg font-medium hover:bg-indigo-800 transition duration-300">AOP详解</a>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white bg-opacity-20 p-6 rounded-xl backdrop-filter backdrop-blur-sm">
                        <div class="mermaid">
                            graph LR
                            A[Spring核心] --> B[IOC]
                            A --> C[AOP]
                            B --> D[控制反转]
                            B --> E[依赖注入]
                            C --> F[动态代理]
                            C --> G[切面编程]
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- IOC Section -->
    <section id="ioc" class="py-16 px-4 bg-white">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center mb-16">
                <span class="inline-block px-4 py-1 bg-indigo-100 text-indigo-700 rounded-full text-sm font-semibold mb-4">控制反转</span>
                <h2 class="text-3xl md:text-4xl font-bold mb-4">IOC (控制反转)</h2>
                <div class="w-20 h-1 bg-indigo-500 mx-auto"></div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-16">
                <div class="bg-gray-50 p-8 rounded-xl shadow-sm card-hover">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-exchange-alt"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">概念解析</h3>
                    <p class="text-gray-700 mb-4">控制反转：把对象的创建权限转交给IOC容器。之前都是自己创建，自己管理对象的生命周期，现在都交给IOC容器来统一的完成。以后需要对象的直接找IOC容器。</p>
                    <p class="text-gray-700 mb-4">使用注解如 <span class="font-mono bg-gray-200 px-2 py-1 rounded">@Controller</span>, <span class="font-mono bg-gray-200 px-2 py-1 rounded">@Service</span>, <span class="font-mono bg-gray-200 px-2 py-1 rounded">@Repository</span> 修饰的类将由IOC容器管理。</p>
                </div>

                <div class="bg-gray-50 p-8 rounded-xl shadow-sm card-hover">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-project-diagram"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">依赖注入(DI)</h3>
                    <p class="text-gray-700 mb-4">DI思想就是依赖注入，主要解决的是bean和bean之间的依赖。例如Controller中需要注入Service。</p>
                    <p class="text-gray-700">使用 <span class="font-mono bg-gray-200 px-2 py-1 rounded">@Autowired</span> 或 <span class="font-mono bg-gray-200 px-2 py-1 rounded">@Resource</span> 注解实现依赖注入。</p>
                    <img src="https://cdn.nlark.com/yuque/0/2021/png/21449790/1635386323967-c5924d97-3cb7-4bfb-96e2-61e2113d94b3.png" alt="IOC示意图" class="mt-4 rounded-lg w-full">
                </div>
            </div>

            <div class="bg-gray-50 p-8 rounded-xl shadow-sm mb-16 card-hover">
                <div class="text-indigo-600 text-4xl mb-4">
                    <i class="fas fa-code"></i>
                </div>
                <h3 class="text-xl font-bold mb-4">底层实现</h3>
                <p class="text-gray-700 mb-6">IOC的底层实现都是通过反射技术来实现的。Spring容器在启动时，会扫描所有组件，通过反射机制创建对象并管理它们的生命周期。</p>
                
                <div class="code-block p-6 mb-6">
                    <pre class="text-sm">
// 传统方式创建对象
User user = new User();

// IOC方式
@Autowired
private UserService userService;  // 由容器注入</pre>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-gray-50 p-8 rounded-xl shadow-sm card-hover">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-lightbulb"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">优点</h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>降低组件间的耦合度</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>提高代码的可测试性</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>统一的配置管理</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>生命周期管理便捷</span>
                        </li>
                    </ul>
                </div>

                <div class="bg-gray-50 p-8 rounded-xl shadow-sm card-hover">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-question-circle"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">常见问题</h3>
                    <div class="space-y-4">
                        <div>
                            <h4 class="font-semibold mb-1">Q: 循环依赖问题如何解决？</h4>
                            <p class="text-gray-700 text-sm">Spring通过三级缓存机制解决循环依赖问题，通过提前暴露对象引用实现。</p>
                        </div>
                        <div>
                            <h4 class="font-semibold mb-1">Q: @Autowired和@Resource的区别？</h4>
                            <p class="text-gray-700 text-sm">@Autowired是Spring提供的，默认按类型注入；@Resource是JSR-250标准，默认按名称注入。</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- AOP Section -->
    <section id="aop" class="py-16 px-4 bg-gray-50">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center mb-16">
                <span class="inline-block px-4 py-1 bg-purple-100 text-purple-700 rounded-full text-sm font-semibold mb-4">面向切面编程</span>
                <h2 class="text-3xl md:text-4xl font-bold mb-4">AOP (面向切面编程)</h2>
                <div class="w-20 h-1 bg-purple-500 mx-auto"></div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-16">
                <div class="bg-white p-8 rounded-xl shadow-sm card-hover">
                    <div class="text-purple-600 text-4xl mb-4">
                        <i class="fas fa-cut"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">概念解析</h3>
                    <p class="text-gray-700 mb-4">AOP是面向切面编程，动态的在某个方法之前或者之后干点事情。</p>
                    <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1649294164056-e11b515a-fa54-489f-be2c-cf85c7086e3b.png" alt="AOP示意图" class="mt-4 rounded-lg w-full">
                </div>

                <div class="bg-white p-8 rounded-xl shadow-sm card-hover">
                    <div class="text-purple-600 text-4xl mb-4">
                        <i class="fas fa-star"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">优势</h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check text-purple-500 mt-1 mr-2"></i>
                            <span>解耦 - 将横切关注点与业务逻辑分离</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-purple-500 mt-1 mr-2"></i>
                            <span>核心业务和系统服务分开</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-purple-500 mt-1 mr-2"></i>
                            <span>业务代码只关注核心业务逻辑</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="bg-white p-8 rounded-xl shadow-sm mb-16 card-hover">
                <div class="text-purple-600 text-4xl mb-4">
                    <i class="fas fa-bell"></i>
                </div>
                <h3 class="text-xl font-bold mb-4">通知类型</h3>
                <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
                    <div class="border-l-4 border-purple-500 pl-4">
                        <h4 class="font-semibold text-purple-700">前置通知</h4>
                        <p class="text-gray-600 text-sm">目标方法之前调用，控制不了目标方法是否调用</p>
                    </div>
                    <div class="border-l-4 border-purple-500 pl-4">
                        <h4 class="font-semibold text-purple-700">后置通知</h4>
                        <p class="text-gray-600 text-sm">目标方法之后调用，抛出异常不会执行</p>
                    </div>
                    <div class="border-l-4 border-purple-500 pl-4">
                        <h4 class="font-semibold text-purple-700">环绕通知</h4>
                        <p class="text-gray-600 text-sm">前置+后置效果，可控制是否调用目标方法</p>
                    </div>
                    <div class="border-l-4 border-purple-500 pl-4">
                        <h4 class="font-semibold text-purple-700">异常通知</h4>
                        <p class="text-gray-600 text-sm">目标方法中出现异常时调用</p>
                    </div>
                    <div class="border-l-4 border-purple-500 pl-4">
                        <h4 class="font-semibold text-purple-700">最终通知</h4>
                        <p class="text-gray-600 text-sm">目标方法之后调用，无论是否抛出异常</p>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-16">
                <div class="bg-white p-8 rounded-xl shadow-sm card-hover">
                    <div class="text-purple-600 text-4xl mb-4">
                        <i class="fas fa-magic"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">动态代理实现</h3>
                    <div class="mb-6">
                        <h4 class="font-semibold text-purple-700 mb-2">JDK动态代理</h4>
                        <ul class="text-gray-700 text-sm space-y-2 ml-4">
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-purple-500 mt-1 mr-2"></i>
                                <span>目标对象必须实现接口</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-purple-500 mt-1 mr-2"></i>
                                <span>通过反射创建代理对象</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-purple-500 mt-1 mr-2"></i>
                                <span>JDK原生支持</span>
                            </li>
                        </ul>
                        <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1689582671226-7e21c38e-9702-46b8-8247-a14da6d61111.png" alt="JDK代理" class="mt-4 rounded-lg w-full">
                    </div>
                    <div>
                        <h4 class="font-semibold text-purple-700 mb-2">CGLIB动态代理</h4>
                        <ul class="text-gray-700 text-sm space-y-2 ml-4">
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-purple-500 mt-1 mr-2"></i>
                                <span>目标对象无需实现接口</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-purple-500 mt-1 mr-2"></i>
                                <span>通过生成子类实现代理</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-purple-500 mt-1 mr-2"></i>
                                <span>需要额外依赖</span>
                            </li>
                        </ul>
                        <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1654234067316-07ac917b-b86d-48fb-a42d-00d7ad5694c9.png" alt="CGLIB代理" class="mt-4 rounded-lg w-full">
                    </div>
                </div>

                <div class="bg-white p-8 rounded-xl shadow-sm card-hover">
                    <div class="text-purple-600 text-4xl mb-4">
                        <i class="fas fa-laptop-code"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">代码示例</h3>
                    <div class="code-block p-6 mb-6">
                        <pre class="text-sm">
@Aspect
public class AopDemo {
    // 前置通知
    @Before("execution(* com.example.service.*.*(..))")
    public void before() {
        System.out.println("方法之前");
    }

    // 环绕通知
    @Around("execution(* com.example.service.*.*(..))")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) {
        System.out.println("方法之前");
        Object proceed = null;
        try {
            // 判断权限
            boolean flag = true;
            if (flag) {
                proceed = proceedingJoinPoint.proceed();
            } else {
                proceed = "你没有权限";
            }
            System.out.println("方法之后");
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        return proceed;
    }
}</pre>
                    </div>
                    <div class="p-4 bg-yellow-50 rounded-lg border-l-4 border-yellow-400">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fas fa-exclamation-circle text-yellow-500 mt-1"></i>
                            </div>
                            <div class="ml-3">
                                <h4 class="font-semibold text-yellow-800">前置通知和环绕通知的区别</h4>
                                <p class="text-yellow-700 text-sm mt-1">前置通知无法控制目标方法是否执行，而环绕通知可以通过ProceedingJoinPoint.proceed()控制是否执行目标方法。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="bg-white p-8 rounded-xl shadow-sm card-hover">
                <div class="text-purple-600 text-4xl mb-4">
                    <i class="fas fa-cogs"></i>
                </div>
                <h3 class="text-xl font-bold mb-4">应用场景</h3>
                <div class="grid md:grid-cols-2 lg:grid-cols-4 gap-6">
                    <div class="text-center p-4 bg-purple-50 rounded-lg">
                        <i class="fas fa-exchange-alt text-purple-600 text-2xl mb-3"></i>
                        <h4 class="font-semibold text-purple-800">事务控制</h4>
                        <p class="text-gray-600 text-sm">使用@Transactional实现声明式事务</p>
                    </div>
                    <div class="text-center p-4 bg-purple-50 rounded-lg">
                        <i class="fas fa-clipboard-list text-purple-600 text-2xl mb-3"></i>
                        <h4 class="font-semibold text-purple-800">日志记录</h4>
                        <p class="text-gray-600 text-sm">统一的方法调用日志记录</p>
                    </div>
                    <div class="text-center p-4 bg-purple-50 rounded-lg">
                        <i class="fas fa-shield-alt text-purple-600 text-2xl mb-3"></i>
                        <h4 class="font-semibold text-purple-800">权限控制</h4>
                        <p class="text-gray-600 text-sm">方法级别的权限校验</p>
                    </div>
                    <div class="text-center p-4 bg-purple-50 rounded-lg">
                        <i class="fas fa-tachometer-alt text-purple-600 text-2xl mb-3"></i>
                        <h4 class="font-semibold text-purple-800">性能监控</h4>
                        <p class="text-gray-600 text-sm">方法执行时间统计</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Comparison Section -->
    <section class="py-16 px-4 bg-white">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center mb-16">
                <span class="inline-block px-4 py-1 bg-blue-100 text-blue-700 rounded-full text-sm font-semibold mb-4">对比分析</span>
                <h2 class="text-3xl md:text-4xl font-bold mb-4">IOC与AOP对比</h2>
                <div class="w-20 h-1 bg-blue-500 mx-auto"></div>
            </div>

            <div class="bg-gray-50 p-8 rounded-xl shadow-sm">
                <div class="mermaid">
                    graph TD
                    A[Spring核心] --> B[IOC]
                    A --> C[AOP]
                    B --> D[控制对象创建]
                    B --> E[管理对象生命周期]
                    B --> F[依赖注入]
                    C --> G[横切关注点]
                    C --> H[动态代理]
                    C --> I[增强方法]
                    D --> J[降低耦合]
                    E --> J
                    G --> K[提高模块化]
                    H --> K
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center">
                <h3 class="text-xl font-bold mb-4">技术小馆</h3>
                <p class="mb-6">深入技术细节，探索架构之美</p>
                <div class="flex justify-center space-x-4">
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300">
                        <i class="fas fa-globe text-xl"></i>
                    </a>
                </div>
                <p class="mt-8 text-gray-400 text-sm">地址: <a href="http://www.yuque.com/jtostring" class="hover:text-white">http://www.yuque.com/jtostring</a></p>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```